package com.buymobile.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.buymobile.dao.TypeDAO;
import com.buymobile.domain.Type;
import com.buymobile.service.TypeService;
import com.buymobile.utils.Constant;

public class TypeServiceImpl implements TypeService {

	private TypeDAO typeDAO;
	
	@Override 
	public void addType(Type type) {
		typeDAO.insert("type.insertType", type);
	}
	
	@Override
	public void deleteType(Integer id) {
//		Type type = new Type();
//		type.setId(id);
//		typeDAO.delete(type);
	}

	@Override
	public List<Type> listAllTypes() {
		Map<String,Object> criteria = new HashMap<String,Object>();
		criteria.put(Constant.ORDER_BY_CLAUSE, "order by id");
		List<Type> types = (List<Type>)typeDAO.queryForList("type.queryTypes",criteria);
		return types;
	}
	
	@Override
	public Type getTypeById(Integer id) {
		return (Type)typeDAO.queryForObject("type.getTypeById", id);
	}
	
	@Override
	public void updateType(Type type) {
		typeDAO.update("type.updateType", type);
		
	}

	public void setTypeDAO(TypeDAO typeDAO) {
		this.typeDAO = typeDAO;
	}

}
